﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections.Specialized;

namespace SaturniLibrary.Web
{
    public class UrlUtility
    {
        public static string ReplaceOrAppendQuery(string queryString, string key, string value)
        {
            if (string.IsNullOrWhiteSpace(queryString))
            {
                return key + "=" + HttpUtility.UrlPathEncode(value);
            }

            NameValueCollection query = HttpUtility.ParseQueryString(queryString);
            query[key] = value;
            return query.ToQueryString();
        }
    }
}
